<template>
  <Card style="height:800px">
    <div>
      <p slot="title" style="color: red;font-size: large;">
        <Icon type="pinpoint"></Icon>
        保单截屏处理
      </p>
      <Row>
        <Input v-model="custName" style="width: 200px;" placeholder="客户姓名"></Input>&nbsp;&nbsp;
        <Input v-model="custCardNo" style="width: 200px;" placeholder="身份证号码"></Input>&nbsp;&nbsp;
        <Input v-model="screenshotsBy" style="width: 200px;" placeholder="处理人"></Input>&nbsp;&nbsp;
        <!-- <Input v-model="channelName" style="width: 100px;" placeholder="处理状态"></Input>&nbsp;&nbsp; -->

        <DatePicker type="date" v-model="startCreatedDate" placeholder="进件日期(起)" style="width: 200px"></DatePicker>—
        <DatePicker type="date" v-model="endCreatedDate" placeholder="进件日期(止)" style="width: 200px"></DatePicker>&nbsp;&nbsp;
        <DatePicker type="date" v-model="screenshotsStartDate" placeholder="处理日期(起)" style="width: 200px"></DatePicker>—
        <DatePicker type="date" v-model="screenshotsEndDate" placeholder="处理日期(止)" style="width: 200px"></DatePicker>&nbsp;&nbsp;

        <Button type="primary" @click="queryPage" style="margin-left: 10px;">查询</Button>
        <!--<Button type="error" @click="getTask" style="margin-left: 10px;">取件</Button>-->
      </Row>
      <Table stripe border :columns="columns1" :data="data1" style="margin-top: 10px;"></Table>

      <div class="page-box">
        <Page :total="totalNumber" size="small" :current="currentPage" :page-size="pageSize" show-total @on-change="pageIndexChange"></Page>
      </div>
    </div>
  </Card>
</template>
<script>

export default {
  data () {
    return {
      $ajax: null,

      path: this.$route.path,
      totalNumber: 0, // 总记录数
      currentPage: 1, // 当前页码
      pageSize: 20, // 页大小
      custName: null,
      custCardNo: null,
      screenshotsBy: null,
      startCreatedDate: null,
      endCreatedDate: null,
      screenshotsStartDate: null,
      screenshotsEndDate: null,
      columns1: [{
        type: 'index',
        width: 65,
        title: '序号'
      },
      {
        title: '进件编号',
        key: 'loanId',
        width: 160
      },
      {
        title: '客户姓名',
        key: 'custName',
        width: 85
      },
      {
        title: '身份证号码',
        key: 'custCardNo',
        width: 165
      },
      {
        title: '保单编号',
        key: 'insuranceId'
      },
      {
        title: '产品名称',
        key: 'productTypeName',
        width: 85
      },
      {
        title: '申请时间',
        key: 'createdDate',
        render: (h, params) => {
          var vm = this
          return h('div', [
            h('span', vm.$util.formatTime(params.row.createdDate))
          ])
        }
      },
      {
        title: '处理人',
        key: 'screenshotsBy',
        width: 80
      },
      {
        title: '处理时间',
        key: 'screenshotsDate',
        render: (h, params) => {
          var vm = this
          return h('div', [
            h('span', vm.$util.formatTime(params.row.screenshotsDate))
          ])
        }
      },
      {
        title: '保险公司',
        key: 'bxCompanyName'
      },
      {
        title: '账号',
        key: 'bxAccountName'
      },
      {
        title: '密码',
        key: 'bxAccountPwd'
      },
      {
        title: '操作',
        key: 'action',
        align: 'center',
        width: 140,
        render: function (h, param) {
          var vm = this
          return h('div', {}, [
            h('Button', {
              props: {
                type: 'info',
                size: 'small'
              },
              style: {
                fontSize: '12px'
              },
              on: {
                'click' () {
                  var params = {}
                  params.loanId = param.row.loanId
                  params.insuranceId = param.row.insuranceId
                  vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/refusedDate', params).then(re => {
                    var data = re.data
                    if (data.data === 0) {
                      vm.$Message.warning('退回出错，请重新退回!')
                    } else {
                      vm.$Message.success('退回成功!')
                      vm.queryPage()
                    }
                  }).catch(er => {
                    vm.$Message.error(er.message)
                  })
                }
              }
            }, '退回 '),
            h('Button', {
              props: {
                type: 'info',
                size: 'small'
              },
              style: {
                marginLeft: '10px'
              },
              on: {
                'click' () {
                  var params = {}
                  params.loanId = param.row.loanId
                  params.insuranceId = param.row.insuranceId
                  vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/submitDate', params).then(re => {
                    var data = re.data
                    if (data.data === 0) {
                      vm.$Message.warning('保单未截屏，请先截屏!')
                    } else {
                      vm.$Message.success('保存成功!')
                      vm.queryPage()
                    }
                  }).catch(er => {
                    vm.$Message.error(er.message)
                  })
                }
              }

            }, '完成')

          ])
        }.bind(this)
      }

      ],
      data1: [

      ]

    }
  },

  methods: {
    pageIndexChange (pageIndex) {
      this.currentPage = pageIndex
      this.queryPage()
    },

    initPage () {
      this.queryPage()
    },

    queryPage () {
      const vm = this
      var params = {
        pageNum: vm.currentPage,
        pageSize: vm.pageSize,
        // curNodeCode:'woCreditInspection',  //页面上写死的
        curNodeCodes: ['woCreditInspection'],
        custCardNo: vm.custCardNo,
        screenshotsBy: vm.screenshotsBy,
        custName: vm.custName,
        startCreatedDate: vm.startCreatedDate,
        endCreatedDate: vm.endCreatedDate,
        screenshotsStartDate: vm.screenshotsStartDate,
        screenshotsEndDate: vm.screenshotsEndDate
      }
      vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/getScreenshotsList', params).then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        vm.data1 = re.data.data.list
        vm.totalNumber = re.data.data.total
      }).catch(er => {

      })
    }

    // getTask () {
    //   const vm = this
    //   var params = {
    //     curNodeCode: 'woCreditInspection' // 页面上写死的
    //   }
    //   vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/getTask', params).then(re => {
    //     var data = re.data
    //     var code = data.code
    //     var message = data.message
    //     if (code === 'success') {
    //       alert('取件成功!')
    //       vm.$router.go(0)
    //     } else {
    //       this.$Message.warning(message)
    //     }
    //   }).catch(er => {

    //   })
    // }

  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
    this.initPage()
  }
}
</script>

<style lang="less">
@import '../../../styles/common.less';
@import '../../../styles/table.less';
</style>
